package ZoneId_Demo;

import java.time.LocalDate;
import java.time.MonthDay;

public class LocalDateDemo {
    public static void main(String[] args) {
        //获取当前时间
        LocalDate now = LocalDate.now();
        System.out.println("目前时间" + now);
        //获取指定时间的对象
        LocalDate ldDate = LocalDate.of(2023,11,14);
        System.out.println("指定时间" + ldDate);
        //get 获取日历中的每一个属性
        int year = ldDate.getYear();
        int month = ldDate.getMonthValue();
        System.out.println(year + ", " + month);

        //获取日
        int dayOfMonth = ldDate.getDayOfMonth();
        System.out.println(dayOfMonth);

        //获取年中的日
        int dayOfYear = ldDate.getDayOfYear();
        System.out.println(dayOfYear);

        //is 开头 比较
        LocalDate ld1 = ldDate.minusDays(1);
        System.out.println(ld1.isBefore(ldDate));

        //with开头的修改
        LocalDate ld2 = ldDate.withYear(2000);
        System.out.println(ld2);

        //minus减小

        //判断今天是否是你生日
        LocalDate bir = LocalDate.of(2004,12,14);
        LocalDate now2 = LocalDate.now();
        MonthDay bir1 = MonthDay.of(bir.getMonth(),bir.getDayOfMonth());
        MonthDay now3 = MonthDay.of(now2.getMonth(),now2.getDayOfMonth());
        System.out.println("今天是你的生日吗" + bir1.equals(now3));
    }
}
